<template>
  <div id="app">
    <!-- 导航菜单 -->
    <nav>
      <router-link to="/">首页</router-link> |
      <router-link to="/vue2-sub-app1">子应用1</router-link> |
      <router-link to="/vue2-sub-app2">子应用2</router-link>
    </nav>
    
    <!-- 主应用路由视图 -->
    <router-view v-if="!isSubApp"></router-view>
    
    <!-- 子应用挂载点 -->
    <div id="subapp-viewport" v-if="isSubApp"></div>
  </div>
</template>

<script>
export default {
  name: 'App',
  computed: {
    // 判断当前路由是否是子应用路由
    isSubApp() {
      return this.$route.path.startsWith('/vue2-sub-app1') || 
             this.$route.path.startsWith('/vue2-sub-app2')
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
  text-decoration: none;
  margin: 0 10px;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style> 